import math


class Solution(object):
    def minSpeedOnTime(self, dist, hour):
        n = len(dist)
        if hour <= n - 1:
            return -1
        left = 1
        right = 10 ** 7

        def search(speed):
            time = 0
            for i in range(n - 1):
                time = math.ceil(time + dist[i] / speed)
            time = time + dist[-1] / speed
            return time <= hour

        while left < right:
            mid = (left + right) // 2
            if search(mid):
                right = mid
            else:
                left = mid + 1
        return right